package cn.keniykey.mc.viewlibrary.reflection;

import java.lang.reflect.Method;

import javax.annotation.Nullable;

/**
 * 反射方法的动态执行
 */
public final class ReflectionDynamicMethod {
	private final Method method;
    private final Object obj;
    
    public ReflectionDynamicMethod(final Method method,final Object obj) {
        this.method = method;
        this.obj = obj;
    }
    
    @Nullable
    public Object execute(final Object... params) {
        try {
            return this.method.invoke(this.obj, params);
        }catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}